import urllib2,json,re


def get_list_url():
 data_url="https://dc.3.cn/category/get"
 result_list=[]
 response = urllib2.urlopen(data_url).read()
 json_data=json.loads(response.decode("gbk"))["data"]
 for item in json_data:
     data2=item["s"]
     for item2 in data2:
       data3=item2["s"]
       for item3 in data3:
           data4=item3["s"]
           for item4 in data4:
               matchObj = re.search(r'(.*?)\|',item4["n"],re.M|re.I)
               if matchObj:
                raw_list_url=matchObj.group(1)
                matchUrl = re.search(r'^\d{3}.*',raw_list_url,re.M|re.I)
                if matchUrl:
                    list_url="https://list.jd.com/list.html?cat="+matchUrl.group()
                    result_list.append(list_url)
                else:
                    list_url="https://"+raw_list_url
                    result_list.append(list_url)
 return result_list








if __name__ == "__main__":
 result_list=get_list_url()
 print len(result_list)
